using System.Security.Principal;
using System.Web;
using DotNetOpenAuth.OpenId.RelyingParty;

namespace TheBoard.Models
{
    public class GetCurrentUserFromOpenIdIdentity: IGetCurrentUser
    {
        private readonly HttpContextBase _context;

        public GetCurrentUserFromOpenIdIdentity(HttpContextBase context)
        {
            _context = context;
        }

        public IUser User
        {
            get { var identity = _context.User.Identity as IUser;
                return identity ?? new User();
            }
        }
    }

    public class KeyAndPrincipal
    {
        public string Key { get; set; }
        public IPrincipal Principal { get; set; }
    }
    public interface IOpenIdSessions
    {
        string SessionCookieName { get; }
        KeyAndPrincipal CreatePrincipal(IAuthenticationResponse response);
        IPrincipal TryGetPrincipal(string key);
        void SetPrincipal(string key, IPrincipal principal);
        void RemovePrincipal(string value);
    }
}